package org.scorpio.account.controller;

import org.scorpio.account.pojo.exception.LoginFailedException;
import org.scorpio.account.pojo.vo.HttpResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * Title:LoginController
 * </p>
 * <p>
 * Description: 登录接口
 * </p>
 * <p>
 * Company:
 * </p>
 * 
 * @author Li Enbo
 * @date 2017年11月7日下午5:19:37
 */
@RestController
@RequestMapping(value = "/", produces = "application/json;charset=UTF-8")
public class LoginController {
    private Logger logger = LoggerFactory.getLogger(LoginController.class);

	/**
	 * 登录
	 * 
	 * @param loginName
	 *            登录名称
	 * @param password
	 *            登录密码
	 * @return
	 */
	@PostMapping("login")
	public HttpResult<String> login(@RequestParam(required = true) String loginName,
			@RequestParam(required = true) String password) throws LoginFailedException {
		// TODO 1、用户spring security验证 2、用户session保存
		logger.info("用户登录");
		HttpResult<String> result = new HttpResult<String>(1001, "", "");
		result.setCode(1001).setMsg("欢迎登陆").setData("{٩(๑❛ᴗ❛๑)۶٩(๑❛ᴗ❛๑)۶٩(๑❛ᴗ❛๑)۶٩(๑❛ᴗ❛๑)۶}");
		return result;
	}

	/**
	 * 登出
	 * 
	 * @return
	 */
	@RequestMapping(value = "logout")
	public HttpResult<String> logout() throws LoginFailedException {
		// TODO 销毁session
		return null;
	}
}
